package com.powernode.controller;

import com.powernode.domain.User;
import com.powernode.service.UserService;
import com.powernode.utils.PowerAuthMenuUtil;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

@RestController
@RequestMapping("/p/user")
@Api(tags = "小程序获取角色头像等信息")
public class UserController {

    @Autowired
    private UserService userService;

    @PostMapping("/loadUserById")
    List<User> loadUserById(@RequestBody List<String> userIds) {
        List<User> userList = userService.loadUserById(userIds);
        return userList;
    }

    @PutMapping("/setUserInfo")
    ResponseEntity<Void> setUserInfo(@RequestBody User user) {
        user.setUserId(PowerAuthMenuUtil.getWxUserId());
        user.setModifyTime(new Date());
        userService.updateById(user);
        return ResponseEntity.ok().build();
    }
}
